"use strict";
/* Controllers */
app.controller("healthScoreAddController", ['$scope', '$location', '$rootScope', '$q', '$routeParams', 'healthScoreAddService', function ($scope, $location, $rootScope, $q, $routeParams, healthScoreAddService) {
    var vm = $scope.vm;
    vm.p = vm.result = {};
    vm.p.tag = $routeParams.tag;
    vm.p.appId = $routeParams.appid;
    vm.p.appName = $routeParams.name;
    vm.p.ownerId = $routeParams.owner;



    if(vm.p.tag=='task') {
        vm.p.typeCode='计算白名单';
    }else {
        vm.p.typeCode='存储白名单';
    }
    vm.p.typeDesc = '-';
    vm.p.itemKey = vm.p.appId;
    vm.p.itemValue = getNowFormatDate(368);
    vm.p.itemDesc = vm.p.appName;

    var errorFn = function (result) {
        alert(result);
    };

    $scope.setHealthScore = function () {
        var vm = $scope.vm;
        var params = vm.p;
        var procFn = function (response) {
            if (response.success && response.data) {
                alert("保存成功！")
            } else {
                alert(response.msg);
            }
        };
        return healthScoreAddService.setHealthScore(params, procFn, errorFn);
    };

}]);


/* Services */
app.service('healthScoreAddService', ['ajaxService', function (ajaxService) {

    this.setHealthScore = function (params, successFunction, errorFunction) {
        ajaxService.AjaxPost(params, "/star/api/basic-service/v1/healthScore/setHealthScore.do", successFunction, errorFunction);
    };
}]);

